// import Level from "@/store/modules/level";
// import User from "@/store/modules/user";
import Lang from "../language/game"

export default {
  timeSpeed: 1000,

  attr:[
    {name:'修炼',field:'expSpeedBuff'},
    {name:'突破',field:'levelUpOddsBuff'},
    {name:'灵魂',field:'soulBuff'},
    {name:'回血',field:'hotBuff'},
    {name:'血量',field:'hpBuff'},
    {name:'寿元',field:'lifeBuff'},
    {name:'历练',field:'travelSpeedBuff'},
  ],
  /**
   * 获取背包大小
   * @returns {number}
   */
  getUserBoxSize(userInfo){
    let soul = userInfo.soul;
    let soulBuff = userInfo.buff.soul;
    return Math.ceil(soul+soulBuff);
  },

  /**
   * 已使用背包大小
   * @param userBox
   * @returns {number}
   */
  getUserBoxUseSize(userBox){
    let sum = 0;
    sum = userBox.pill.length+userBox.subject.length+userBox.arms.length
    return Math.ceil(sum);
  },

  /**
   * 获取学习功法大小
   * @returns {number}
   */
  getUserSubjectSize(userInfo){
    let soul = userInfo.soul;
    let soulBuff = userInfo.buff.soul;
    return Math.ceil((soul+soulBuff)/10);
  },
  /**
   * 获取法宝大小
   * @returns {number}
   */
  getUserArmsSize(userInfo){
    let soul = userInfo.soul;
    let soulBuff = userInfo.buff.soul;
    return Math.ceil((soul+soulBuff)/10);
  },
  /**
   * 获取好友大小
   * @returns {number}
   */
  getUserMateSize(userInfo){
    let soul = userInfo.soul;
    let soulBuff = userInfo.buff.soul;
    return Math.ceil((soul+soulBuff)/10);
  },

  /**
   * 获取当前时间
   * @returns {string}
   */
  getDate(user){
    return user.other.year + Lang.userInfoPanel.year + user.other.month + Lang.userInfoPanel.month;
  },

  /**
   * 是否保留属性物品
   * @param obj
   * @param configAttr
   */
  keepAttr(obj,configAttr){
    // console.info(obj);
    // console.info(configAttr);
    let keep = false;
    for (let i=0;i<configAttr.length;i++){
      // 修为
      if(configAttr[i]===0 && obj.expSpeedBuff>0){
        keep = true;
        break;
      }
      // 突破
      if(configAttr[i]===1 && obj.levelUpOddsBuff>0){
        keep = true;
        break;
      }

      // 灵魂
      if(configAttr[i]===2 && obj.soulBuff>0){
        keep = true;
        break;
      }

      // 回血
      if(configAttr[i]===3 && obj.hotBuff>0){
        keep = true;
        break;
      }

      // 血量
      if(configAttr[i]===4 && obj.hpBuff>0){
        keep = true;
        break;
      }

      // 寿元
      if(configAttr[i]===5 && obj.lifeBuff>0){
        keep = true;
        break;
      }

      // 历练
      if(configAttr[i]===6 && obj.travelSpeedBuff>0){
        keep = true;
        break;
      }
    }

    return keep;
  }
}
